<template>
    <div>
      <button v-if="showBth" @click="changeView">点击搜索</button>
      <input v-else type="text" v-model="keyWord" placeholder="输入要搜索的关键字" ref="inp">
    </div>
  </template>
  
  <script>
  export default {
    data(){
      return{
        showBth:true,
        keyWord: ''
      }
    },
    methods:{
      changeView(){
        this.showBth = false
        this.$nextTick(()=>{
          this.$refs.inp.focus()
        })
      }
    }
  }
  </script>
  
  <style>
  
  </style>